package com.jiuyue.movehouse.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiuyue.movehouse.annotion.PageInfo;
import com.jiuyue.movehouse.entity.Car;
import com.jiuyue.movehouse.entity.Order;
import com.jiuyue.movehouse.service.CarService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yourFather
 * @since 2022-02-12
 */
@RestController
@RequestMapping("/car")
@AllArgsConstructor
public class CarController {

    private CarService carService;

    @GetMapping("getCarList")
    public Page<Car> getCarList(@PageInfo Page<Car> page, Car car) {
        return carService.getCarList(page, car);
    }

    @PostMapping("saveCar")
    public void saveCar(@RequestBody @Validated(Car.Save.class) Car car) {
        carService.saveCar(car);
    }

    @PutMapping("updateCar")
    public void updateCar(@RequestBody @Validated(Car.Update.class) Car car) {
        carService.updateCar(car);
    }

    @DeleteMapping("deleteCar/{carId}")
    public void deleteCar(@PathVariable Long carId) {
        carService.deleteCar(carId);
    }
}

